import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/widget/image_asset_widget.dart';
import 'package:oktoast/oktoast.dart';
import 'package:yysk_app/utils/helper.dart';

class CardListTileWidget extends StatelessWidget {
  final EdgeInsets? padding;
  final EdgeInsets? margin;
  final String label;
  final String value;
  final String? fontFamily;
  final bool? canCopy;
  const CardListTileWidget({
    super.key,
    this.padding,
    this.margin,
    required this.value,
    required this.label,
    this.canCopy = false,
    this.fontFamily = '',
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: padding,
      margin: margin ?? EdgeInsets.only(top: 12.px),
      child: Row(
        // mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          SizedBox(
            width: 76.px,
            child: Text(
              label,
              style: TextStyle(
                fontSize: 12.px,
                color: AppColors.fontColorGray99,
              ),
              textAlign: TextAlign.left,
            ),
          ),
          canCopy == true
              ? Expanded(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Container(
                      constraints: BoxConstraints(maxWidth: 200.px),
                      child: Text(
                        value,
                        style: TextStyle(
                          fontSize: 12.px,
                          color: AppColors.fontColor,
                          overflow: TextOverflow.ellipsis,
                          fontFamily: fontFamily,
                        ),
                      ),
                    ),
                    SizedBox(width: 4.px),
                    GestureDetector(
                      child: ImageAssetWidget(
                        imageUrl: 'static/images/mine/copy.png',
                        width: 12.px,
                        height: 12.px,
                      ),
                      onTap: () {
                        Clipboard.setData(ClipboardData(text: value));
                        showToast('复制成功');
                      },
                    ),
                  ],
                ),
              )
              : Container(
                constraints: BoxConstraints(maxWidth: 200.px),
                child: Text(
                  value,
                  style: TextStyle(
                    fontSize: 14.px,
                    color: AppColors.fontColor,
                    overflow: TextOverflow.ellipsis,
                    fontFamily: fontFamily,
                  ),
                ),
              ),
        ],
      ),
    );
  }
}
